package edu.fjnu.datagenerator.campusTraffic;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;
import java.util.Random;

/**
 * Created by hadoop on 16-3-25.
 */
public class CampusTrafficEntity {

    private String carId;
    private String date;
    private String licensePlate;
    private String identity;


    public String getCarId() {
        return carId;
    }

    public void setCarId(String carId) {
        this.carId = carId;
    }


    public String getDate() {
        return date;
    }

    public void setDate(String date) {
        this.date = date;
    }

    public String getLicensePlate() {
        return licensePlate;
    }

    public void setLicensePlate(String licensePlate) {
        this.licensePlate = licensePlate;
    }

    public String getIdentity() {
        return identity;
    }

    public void setIdentity(String identity) {
        this.identity = identity;
    }

    //车辆编号增长
    public String getCarIdByASC(int carid) {
        return carId = String.valueOf(carid + 1);
    }

    //随机生成车主身份
    public String getIdentityByRandom() {

        Random random = new Random();
        int result = random.nextInt(10);
        if (result <= 1) {
            identity = "外来人员";
        } else if (result <= 6) {
            identity = "学生";
        } else {
            identity = "老师";
        }
        return identity;
    }

    //随机生成车牌号
    public String getLicensePlateByRandom() {
        Random random = new Random();
        int number = random.nextInt(88888) + 11111;
        String[] alphabet = {"A", "B", "C", "D", "E", "F", "G", "H", "J", "K"};
        int i = random.nextInt(9);
        licensePlate = "闽" + alphabet[i] + number;
        return licensePlate;
    }

    //随机生成递增时间,yyyy-MM-dd HH:mm:ss
    public String getDateByRandom(String Date) {
        GregorianCalendar cal = new GregorianCalendar();
        int second;
        try {
            SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
            Date dateTime = sdf.parse(Date);
            cal.setTime(dateTime);
            Random random = new Random();
            second = random.nextInt(599) + 1;
            cal.add(Calendar.SECOND, second);
            date = (new SimpleDateFormat("yyyy-MM-dd HH:mm:ss")).format(cal.getTime());
        } catch (ParseException e) {
            System.out.println(e.getMessage());
        }

        return date;

    }
}
